var xmlHttp; 

function createXMLRequest(){
	if(window.ActiveXObject){
		xmlHttp=new ActiveXObject("Microsoft.XMLHttp");
	} else if(window.XMLHttpRequest){
		xmlHttp=new XMLHttpRequest();
	}
}

function addReply(topic){  
	createXMLRequest();       
	var editor=document.getElementById("editor").innerHTML; 
	editor=editor.replace(/\+/g,"*");
	editor=editor.replace(/\;/g,"}");          
	xmlHttp.open("POST","/groups/topic/comment/");
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4 && xmlHttp.status==200){
			var result=eval('('+xmlHttp.responseText+')');  
			//alert(result.name);
			//re_array=xmlHttp.responseText.split(',');
			var str1='<div id="ajax_comment"></div><div style="margin-top:20px;"><div class="commentDiv1 pull-left"><img src='+result.commit_id+' class="img-circle" width="100%"/></div>';
	        var str2='<div class="pull-left commentDiv2"><div class="topdirection_left pull-left"></div><div class="commentDiv21 pull-left">';
	        var str3='<div><div class="pull-left time">'+result.name+'</div><div class="pull-right time">刚刚更新</div><div class="clearfix"></div></div>';
	        var str4='<div>'+content+'</div><div style="text-align:right;">';
	        if (result.img != "") {
	        	str7 = ""
	        	for (var i = 0; i < result.img.length; i++;) {
	        		
	        		str7 += "<img src="+result.img[i]+"/>"
	        	}
	        }
	        var str5='<span class="span_news"><a href="javascript:void(0)" onclick="clickgood('+result.commit_id+')"><i class="icon-thumbs-up"></i> <span id="good'+result.commit_id+'">'+result.good_con+'</span></a></span>';
	        var str6='<span class="span_news"><a href="javascript:void(0)" onclick="topic_cocomment('+result.commit_id+',\''+result.name+'\');"><i class="icon-comment"></i> <span id="rerecomment_con'+result.commit_id+'">'+result.reviewCon+'</span></a></span></div></div><div class="clearfix"></div></div><div class="clearfix"></div></div>';
	       
	       if (result.img != "") {
	        	var strr=str1+str2+str3+str4+str5+str6+str7;
	        } else {
	        	var strr=str1+str2+str3+str4+str5+str6;
	        }

			if(isNaN(result.commit_id)){
				e.preventDefault();
	    		$.scojs_message('服务器出错啦～ ：）', $.scojs_message.TYPE_ERROR);
			} else {
				$("#ajax_comment").html(strr);
				$("#ajax_comment").removeAttr("id");
				$("#comment").val('');
				$("#group_comment").hide();
				$("#reviewOfTopic_con"+topic).html(parseInt($("#reviewOfTopic_con"+topic).html())+1);
				//alert($("#rerecomment_con"+re_array[0]).html());
				//$("#rerecomment_con"+re_array[0]).html(parseInt($("#rerecomment_con"+re_array[0]).html())+1);
				e.preventDefault();
	    		$.scojs_message('您回复成功！', $.scojs_message.TYPE_OK);
			}
		} else {
			e.preventDefault();
	    	$.scojs_message('服务器有小怪兽在捣乱～我们正在尽力捕捉～ ：）', $.scojs_message.TYPE_ERROR);
		}
	};
	xmlHttp.send("id="+topic+"&content="+editor); 
}